package test;

public class Student {
    private String id;         // 学生编号
    private String name;       // 姓名
    private String gender;     // 性别
    private Course selectedCourse; // 所选课程

    // 构造方法
    public Student(String id, String name, String gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }

    // 选课方法
    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println("学生" + name + "成功选修课程《" + course.getName() + "》");
    }

    // 退课方法
    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println("学生" + name + "已退选课程《" + selectedCourse.getName() + "》");
            selectedCourse = null;
        } else {
            System.out.println("学生" + name + "当前未选修任何课程，无法退课");
        }
    }

    // 打印个人课表方法
    public void printSchedule() {
        if (selectedCourse != null) {
            System.out.println("=====学生" + name + "的课表=====");
            System.out.println("课程编号：" + selectedCourse.getId());
            System.out.println("课程名称：" + selectedCourse.getName());
            System.out.println("上课地点：" + selectedCourse.getLocation());
            System.out.println("上课时间：" + selectedCourse.getTime());
            System.out.println("授课教师编号：" + selectedCourse.getTeacherId());
            System.out.println("=====================");
        } else {
            System.out.println("学生" + name + "当前无选课记录");
        }
    }

    // Getter方法
    public String getId() { return id; }
    public String getName() { return name; }
    public Course getSelectedCourse() { return selectedCourse; }
}

